home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d3 / rettig.arc / TRSOURCE.EXE / POKESTR.ASM < prev    next >
Assembly Source File  |  1990-10-22  |  3KB  |  96 lines

  1. ; POKESTR.ASM
  2. ;
  3. ; by Ralph Davis
  4. ; modified by Leonard Zerman
  5. ;
  6. ; Placed in the public domain by Tom Rettig Associates, 10/22/1990.
  7. ;
  8.  
  9.          PUBLIC   POKESTR
  10.  
  11.          INCLUDE  EXTENDA.MAC
  12.  
  13.          EXTRN    _TR_POKE_PARMS:FAR
  14.  
  15. DGROUP GROUP _DATA
  16. ;*****************************************************
  17. _DATA  SEGMENT  WORD PUBLIC 'DATA'
  18.  
  19. ;
  20. ;    Saves input segment and offset
  21. ;
  22. SEG_ADDR    DW       ?
  23. OFF_ADDR    DW       ?
  24. ;
  25. _DATA  ENDS
  26. ;*****************************************************
  27.  
  28. ;*****************************************************
  29. POKESTR_TEXT SEGMENT BYTE PUBLIC 'CODE'
  30.          ASSUME   CS:POKESTR_TEXT, DS:_DATA
  31. ;-----------------------------------------------------
  32. ;
  33. ;     POKESTR(segment, offset, string)
  34. ;
  35. ;        segment = SPACE(4)    && hexadecimal string
  36. ;        offset  = number < 65536 or hexadecimal string
  37. ;        string  = <expC>
  38. ;
  39. ;        Returns:  .F. if less than three parameters passed
  40. ;                  .T. otherwise
  41. ;
  42. ;        NOTE:  This function will let you overwrite anything.
  43. ;
  44. ;--------------
  45. POKESTR  PROC     FAR
  46.          PUSH     BP
  47.          MOV      BP,SP
  48.          PUSH     DS
  49.          PUSH     ES
  50.          PUSH     DX
  51.          PUSH     SI
  52.          PUSH     DI
  53.          CALL     _TR_POKE_PARMS ; returns segment in DX,
  54.                                  ; returns offset in AX
  55.          JL       POKESTR_ERR    ; Sign flag set means less than 2 parms
  56.          PUSH     DS             ; Save caller's DS
  57.          MOV      BX,_DATA        ; Point DS to our data segment
  58.          MOV      DS,BX
  59.          MOV      SEG_ADDR,DX
  60.          MOV      OFF_ADDR,AX
  61.          POP      DS             ; Restore caller's DS
  62.          GET_CHAR 3              ; get source string
  63.          PUSH     DX             ; save segment of source string
  64.          MOV      DX,_DATA        ; Point to our data segment
  65.          MOV      DS,DX
  66.          MOV      SI,AX
  67.          MOV      DI,OFF_ADDR    ; retrieve offset
  68.          MOV      DX,SEG_ADDR    ; retrieve segment
  69.          MOV      ES,DX          ; and place in ES
  70.          POP      DX             ; get segment of source string
  71.          MOV      DS,DX          ; and place it in DS
  72. POKE_STR_GETSTR:
  73.          LODSB                   ; pick up byte from source string
  74.          OR       AL,AL          ; is it NULL character?
  75.          MOV      BX,1           ; return .T. for successful completion
  76.          STOSB                   ; no, so put it into destination
  77.          JZ       SHORT POKESTR_EXIT   ; yes, so we're done
  78.          JMP      SHORT POKE_STR_GETSTR
  79. POKESTR_ERR:
  80.          MOV      BX,0           ; return .F. for error
  81. POKESTR_EXIT:
  82.          POP      DI
  83.          POP      SI
  84.          POP      DX
  85.          POP      ES
  86.          POP      DS
  87.          POP      BP
  88.          RET_LOGICAL BX          ; Return .T. or .F. to caller
  89.          RET
  90. POKESTR ENDP
  91. ;------------------------------------------------
  92. POKESTR_TEXT   ENDS
  93. ;************************************************
  94.          END
  95.  
  96.